package com.sunwayhorizo.health.hl7.rim;

import com.sunwayhorizo.health.common.DataTypeUtil;
import com.sunwayhorizo.health.hl7.common.Hl7Exception;
import com.sunwayhorizo.health.hl7.datatypes.PQ;
import com.sunwayhorizo.health.hl7.factories.ReferenceModifier;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.NamedQuery;

import org.jboss.seam.annotations.Name;


@Name("Diet")
@Entity
@NamedQuery(name = "Diet.findAll", query = "select o from Diet o")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorValue("DIET")
public class Diet extends Supply implements Serializable {
    
//    public PQ carbohydrateQuantity;
//    public PQ energyQuantity;

    public Diet() throws Hl7Exception {
    }
    
    public Diet(ReferenceModifier referencemodifier)
    {
        super(referencemodifier);
    }

    public void setCarbohydrateQuantity(PQ carbohydrateQuantity) {
        this.setDiCarbQtyTxt(carbohydrateQuantity.value().toString());
        this.setDiCarbQtyUomCode(carbohydrateQuantity.unit().code().toString());
    }

    public PQ getCarbohydrateQuantity() throws Hl7Exception {
        return DataTypeUtil.getPQ(this.getDiCarbQtyTxt(), this.getDiCarbQtyUomCode());
    }

    public void setEnergyQuantity(PQ energyQuantity) {
        this.setDiEnergyQtyTxt(energyQuantity.value().toString());
        this.setDiEnergyQtyUomCode(energyQuantity.unit().code().toString());
    }

    public PQ getEnergyQuantity() throws Hl7Exception {
        return DataTypeUtil.getPQ(this.getDiEnergyQtyTxt(), this.getDiEnergyQtyUomCode());
    }

//Diet    
    @Column(name = "DI_CARB_QTY_TXT")    private String diCarbQtyTxt;
    @Column(name = "DI_CARB_QTY_UOM_CODE")    private String diCarbQtyUomCode;
    @Column(name = "DI_ENERGY_QTY_TXT")    private String diEnergyQtyTxt;
    @Column(name = "DI_ENERGY_QTY_UOM_CODE")    private String diEnergyQtyUomCode;
    
    private String getDiCarbQtyTxt() {
        return diCarbQtyTxt;
    }

    private void setDiCarbQtyTxt(String diCarbQtyTxt) {
        this.diCarbQtyTxt = diCarbQtyTxt;
    }

    private String getDiCarbQtyUomCode() {
        return diCarbQtyUomCode;
    }

    private void setDiCarbQtyUomCode(String diCarbQtyUomCode) {
        this.diCarbQtyUomCode = diCarbQtyUomCode;
    }

    private String getDiEnergyQtyTxt() {
        return diEnergyQtyTxt;
    }

    private void setDiEnergyQtyTxt(String diEnergyQtyTxt) {
        this.diEnergyQtyTxt = diEnergyQtyTxt;
    }

    private String getDiEnergyQtyUomCode() {
        return diEnergyQtyUomCode;
    }

    private void setDiEnergyQtyUomCode(String diEnergyQtyUomCode) {
        this.diEnergyQtyUomCode = diEnergyQtyUomCode;
    }

}
